package com.crm.config;

import com.crm.web.interceptor.AuthorizationInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 自定义拦截器
 */
@Configuration
public class IndexConfig implements WebMvcConfigurer {
    private String[] excludePathPatterns;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] patterns = {"/**"};//拦截路径规则
        String[] excludePathPatterns = {"", "/login", "/dologin", "/css/**",
                "/fonts/**", "/images/**", "/js/**", "/localjs/**"};//排除路径规则
        registry.addInterceptor(new AuthorizationInterceptor())
                .addPathPatterns(patterns)//添加路径规则
                .excludePathPatterns(excludePathPatterns);//添加排除路径规则
    }
}
